package com.czk.springdatar2dbc.config;

import com.czk.springdatar2dbc.config.converter.BookConverter;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.data.r2dbc.convert.R2dbcCustomConversions;
import org.springframework.data.r2dbc.dialect.MySqlDialect;
import org.springframework.stereotype.Component;

/**
 * @Author: chenzhangkun
 * @CreateTime: 2025-05-27
 * @Description:
 * @Version: 1.0
 */
@Component
public class R2DbcConfiguration {

    /**
     * 加入自定义转化器
     *
     * @return
     */
    @Bean
    @ConditionalOnMissingBean
    public R2dbcCustomConversions customConversions(){
        return R2dbcCustomConversions.of(MySqlDialect.INSTANCE,new BookConverter());
    }
}
